home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-04-01 | 3.3 KB | 63 lines | [TEXT/GEOL] |
- Item 7252095 4-March-91 10:59PST
-
- From: ALGER Alger, Jeff,VCA
-
- To: MACAPP.TECH$ MacApp Technical
-
- ------------------------------------------------------------------------------
-
- Sub: Another MA3 opinion (long)
-
- James, Lee, Joe,
-
- James, you have a knack for asking the "dumb" question that leaves everyone
- else scrambling to avoid looking dumb in responding. I agree, it's a pretty
- damning statement to say that the Toolbox is more stable and easier to change
- than object-oriented code in general and MacApp in particular. Let's not deny
- the discomfort, but deal with it constructively.
-
- There is one obvious explanation for this and one not-so-obvious. The obvious
- one, particularly in the MacApp community, is that people take on more
- ambitious projects when armed with MacApp-caliber class libraries. This
- ambition, in itself, leads to bigger maintenance problems than for simpler
- projects.
-
- The more subtle problem strikes at the heart of object-oriented software
- engineering. I recall reading something by Dijkstra back in ancient times
- damning the GOTO statement in simple terms: if GOTOs are allowed in a program,
- you cannot tell by looking at a line of code how you got there. Not that
- GOTO-less programs are perfect in this regard, just better, since sequence (one
- line following another), iteration and selection (IF-THEN) were the only
- control structures. Enter inheritance and polymorphism, the modern equivalent,
- in software engineering terms, of the GOTO. When designing a method, you
- cannot tell whether it will be reached from within the same class, by
- inheritance from a subclass, through a call to INHERITED, or not at all due to
- either a complete override of that method or an override of some other method
- that would otherwise call it. You also cannot tell from looking at a method
- what else it will call when invoked, again because of the possibility of
- overrides of both that method and the receiving end of the calls. No wonder it
- takes a couple of years to get the hang of OOP!
-
- One good technique for overcoming this problem is to design the run-time
- environment first, in which inheritance and polymorphism and, yes, even the
- class library, have been factored out and all that you have are objects, each
- of which has a fixed-for-all-time set of methods with specific implementations.
- Once that architecture is in place, one can create an optimal implementation
- using inheritance and polymorphism in the language (i.e., pre-compilation)
- model and borrow from the class library where appropriate. Another technique
- (implicit in the nested, inherited structure of Eiffel pre- and
- post-conditions, by the way) is to never completely override the behavior of a
- method and always call the INHERITED version at some point. Neal Goldstein has
- coined the term "normal" inheritance for this. "Never" is, of course, an ideal
- not always achievable, but it is amazing how differently one designs class
- hierarchies with this in mind. What this guarantees is that a client can
- always count on a certain basic behavior; the subclass merely enhances the
- behavior. It also leads to the phenomenon you describe, Lee, of being able to
- achieve wide-ranging constructive change with little effort.
-
- This link is already too long, so I'll stop here. Comments, anyone?
-
- Regards,
- Jeff Alger
-
-